/**
 * @Author YuanYuan
 * @Date 2022/11/17
 * @Time 13:41
 */
import java.util.*;
class MyList {
    public int val;
    public MyList next;
    public MyList(int val){
        this.val = val;
        this.next = null;
    }
}

public class TestDemo {
    // 注意类名必须为 Main, 不要有任何 package xxx 信息
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            while (in.hasNextInt()) {
                int n = in.nextInt();
                //头
                MyList head1 = new MyList(in.nextInt());
                MyList cur1 = head1;
                //输入链表
                for(int i = 1;i<n;i++) {
                    int num = in.nextInt();
                    cur1.next = new MyList(num);
                    cur1 = cur1.next;
                }
                cur1 = head1.next;
                int l = in.nextInt();
                int r = in.nextInt();
                MyList head2 = reverseList(head1,l,r);
                MyList cur2 = head2;
                while(cur2!=null) {
                    System.out.print(cur2.val+" ");
                    cur2 = cur2.next;
                }
            }
        }
        private static MyList reverseList(MyList head1,int l,int r) {
            MyList cur1 = head1;
            //l-r头插,其他位置尾插
            MyList head2 = null;
            MyList prev = null;
            //记录位置
            int count = 1;
            //tail 需要指向第一个头
            MyList tail= null;
            while(count<=r) {
                //需要把第一个开始头插的结点的前一个结点保存
                if(count+1 == l) {
                    prev = cur1;
                }
                //翻转
                if(count>=l && count<=r){
                    //头插

                    MyList node = new MyList(cur1.val);
                    node.next = head2;
                    head2 = node;
                    if(count == l) {
                        tail = node;
                    }
                }
                //把翻转完成的链表和前后拼接起来
                cur1 = cur1.next;
                count++;
            }
            if(prev != null) {
                prev.next = head2;
            }else {
                head1 = head2;
            }
            tail.next = cur1;
            return head1;
        }
    }
